import Taro from "@tarojs/taro";
import { RoleType } from "types/user";

//根据code 错误提示
export function ShowErrorInfoByCode(code: number, callback?: Function) {
    console.log("code is ---", code)

    if (code === 602)
        return Taro.showModal({
            title: '错误提示',
            content: '该账号审核未通过，换一个手机号试试',
            showCancel: false,
        });
    if (code === 603)
        return Taro.showModal({
            title: '错误提示',
            content: '该账号已被禁用,换一个手机号试试',
            showCancel: false,
        });

    //找不到该账号
    if (code === 605) {
        Taro.showModal({
            title: '错误提示',
            content: `您登录的手机号未在平台注册，请选择已注册的手机号登录，或联系平台客服注册后再登录`,
            confirmText: '切换身份',
            cancelText: '联系客服',
            success: function ({ cancel, confirm }) {
                if (cancel) callback && callback()
                if (confirm) Taro.redirectTo({ url: '/pages/login/role' })
            }
        });
    }

}


export const ROLE_HOMEPAGE_MAP = {
    [RoleType.用户]: '/pages/index/index',
    [RoleType.专家]: '/pages/expert/appointment/index',
    [RoleType.合伙人]: '/pages/partners/user/index',
};